#define quickread
#ifdef quickread
#include <cstdio> 
template <typename T>
inline void read(T& x)
{
    int c=getchar(), f=1; x=0;
    while(c<'0'||'9'<c) {if(c=='-') f=-1; c=getchar();}
    while('0'<=c&&c<='9') 
        x=(x<<3)+(x<<1)+c-'0', c=getchar();
    x*=f;
}
template <typename T>
inline void quickwrite(T x)
{
    if(x<0) putchar('-'), x*=-1;
    if(x>=10) quickwrite(x/10);
    putchar(x%10+'0');
}
#else 
#include <iostream>
#endif
#include <cstring>
#include <queue>
using namespace std;
#define DEBUG
const int N=1e6+10, M=N<<1, INF=0x3f3f3f3f;
int n, x, y;
int k[N], dist[N]; //当前层可以传送的步数 可加减

int h[N], e[M], ne[M], idx;

queue<int> q;

void AddEdge(int a, int b)
{
    e[idx]=b, ne[idx]=h[a], h[a]=idx++; 
}

void bfs(int st)
{
    q.push(st);
    while(q.size())
    {
        int u=q.front(); q.pop();
        for(int i=h[u]; ~i; i=ne[i])
        {
            int v=e[i];
            if(v==y) {dist[v]=dist[u]+1; return;}
            if(dist[v]<dist[u]+1) continue;
            dist[v]=dist[u]+1;
            q.push(v);
        }
    }
}

void init()
{
    memset(h, -1, sizeof h);
    memset(dist, 0x3f, sizeof dist);
    read(n), read(x), read(y);
    dist[x]=0;
    for(int u=1; u<=n; u++)
    {
        int dis; read(dis);
        if(dis==0) continue;
        if(u-dis>0) AddEdge(u, u-dis);
        if(u+dis<=n) AddEdge(u, u+dis);
    }
}


void solve()
{
    init();
    bfs(x);

    if(dist[y]!=INF) quickwrite(dist[y]);
    else puts("-1");
    puts("");
}

// #undef DEBUG
signed main()
{
    #ifdef DEBUG
        freopen("./in.txt", "r", stdin);
        // freopen("./out.txt", "w", stdout);
    #endif
    #ifndef quickread
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #endif

    int T=1; //scanf("%d", &T);
    while(T--) 
    {
        solve();
    }
    return 0;
}
